/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package modelo;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Caps
 */
@Entity
@Table(name = "questao")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Questao.findAll", query = "SELECT q FROM Questao q"),
    @NamedQuery(name = "Questao.findByIdquestao", query = "SELECT q FROM Questao q WHERE q.idquestao = :idquestao"),
    @NamedQuery(name = "Questao.findByQuestao", query = "SELECT q FROM Questao q WHERE q.questao = :questao"),
    @NamedQuery(name = "Questao.findByValidada", query = "SELECT q FROM Questao q WHERE q.validada = :validada")})
public class Questao implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "idquestao")
    private Integer idquestao;
    @Size(max = 2147483647)
    @Column(name = "questao")
    private String questao;
    @Column(name = "validada")
    private Boolean validada;
    @JoinColumn(name = "categoria", referencedColumnName = "idcategoria")
    @ManyToOne
    private Categoria categoria;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "questao")
    private List<QuestionarioHasQuestao> questionarioHasQuestaoList;

    public Questao() {
    }

    public Questao(Integer idquestao) {
        this.idquestao = idquestao;
    }

    public Integer getIdquestao() {
        return idquestao;
    }

    public void setIdquestao(Integer idquestao) {
        this.idquestao = idquestao;
    }

    public String getQuestao() {
        return questao;
    }

    public void setQuestao(String questao) {
        this.questao = questao;
    }

    public Boolean getValidada() {
        return validada;
    }

    public void setValidada(Boolean validada) {
        this.validada = validada;
    }

    public Categoria getCategoria() {
        return categoria;
    }

    public void setCategoria(Categoria categoria) {
        this.categoria = categoria;
    }

    @XmlTransient
    public List<QuestionarioHasQuestao> getQuestionarioHasQuestaoList() {
        return questionarioHasQuestaoList;
    }

    public void setQuestionarioHasQuestaoList(List<QuestionarioHasQuestao> questionarioHasQuestaoList) {
        this.questionarioHasQuestaoList = questionarioHasQuestaoList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idquestao != null ? idquestao.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Questao)) {
            return false;
        }
        Questao other = (Questao) object;
        if ((this.idquestao == null && other.idquestao != null) || (this.idquestao != null && !this.idquestao.equals(other.idquestao))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "modelo.Questao[ idquestao=" + idquestao + " ]";
    }
    
}
